/*
 * Serum
 *
 * @license      GNU Lesser General Public Licence see LICENCE-LGPL file or http://www.gnu.org/licenses/lgpl.html
 */

/**
 * Preferences helper
 */
Serum.Preferences = function() {
    var _instance = null;

    /**
     * Constructor
     */
    var __construct = function() {
        return {
            /**
             * Bundles
             */
            values:    {},
            
            /**
             * Loads preferences
             * 
             * @param   {Object}    preferences
             */
            load: function(preferences) {
                for (var preference in preferences) {
                    this.values[preference] = preferences[preference];
                }
            },

            /**
             * Retrieves value
             *
             * @param   {String}    key
             * @return  {String}
             */
            getValue: function(key) {
                if (typeof this.values[key] !== 'undefined') {
                    return this.values[key];
                }

                return null;
            }
        }
    };

    return {
        /**
         * Returns instance
         *
         * @return  {Serum.Preferences}    Instance
         */
        get: function() {
            if (_instance === null) {
                _instance = __construct();
            }
            return _instance;
        }
    };
}();